home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 23
/
Amiga Format AFCD23 (Feb 1998, Issue 107).iso
/
-seriously_amiga-
/
shareware
/
programming
/
e
/
easyplugins
/
source
/
icongad.e
< prev
next >
Wrap
Text File
|
1997-12-06
|
3KB
|
112 lines
/*
$VER: IconGad Plugin V1.00
Written by: Fabio Rotondo (fsoft@intercom.it)
Fixed and enhanced by: Jason Hulance (jason@fsel.com)
This PLUGIN is part of EasyGUI PLUGINs distribution
NOTE: Comments between /* */ are mine (Fabio)
Comments satrting with -> are from Jason
*/
OPT OSVERSION=37
OPT MODULE
OPT EXPORT
MODULE 'workbench/workbench',
'exec/ports',
'icon',
'intuition/screens', 'intuition/intuition',
'gadtools', 'libraries/gadtools',
'tools/easygui', 'tools/Exceptions'
/*
This is our new plugin.
Note the PRIVATE keyword:
we don't want the user to access these fields.
*/
OBJECT icongad_plugin OF plugin
PRIVATE
dobj:PTR TO diskobject
-> Have our own gadget (don't use dobj's gadget)
gad:PTR TO gadget
ENDOBJECT
/*
This is the init proc for the plugin.
You must provide a valid icon name (full path)
without the ".info" extension (it is added automagically
by GetDiskObject() call)
*/
PROC init(fname) OF icongad_plugin
IF (iconbase:=OpenLibrary('icon.library', 0))=NIL THEN Raise("ilib")
self.dobj := GetDiskObject(fname)
IF self.dobj = NIL THEN Raise("icon")
-> Copy the relevant parts of dobj to our gadget
-> The *vital* part is the initialisation of the "activation" field to
-> a known value (GACT_RELVERIFY). That way, we know what IDCMP messages
-> the gadget will generate.
self.gad:=NEW [NIL, 0, 0, self.dobj.gadget.width, self.dobj.gadget.height,
self.dobj.gadget.flags, GACT_RELVERIFY,
self.dobj.gadget.gadgettype,
self.dobj.gadget.gadgetrender,
self.dobj.gadget.selectrender,
NIL, 0, NIL, 0, NIL]:gadget
ENDPROC
/*
We free all Alloc()ed resources.
Remeber to always END your PLUGINs before program termination.
*/
PROC end() OF icongad_plugin
IF self.dobj THEN FreeDiskObject(self.dobj)
IF iconbase THEN CloseLibrary(iconbase)
END self.gad
ENDPROC
/* The icon cannot be stretched, so it cannot be resized... */
PROC will_resize() OF icongad_plugin IS FALSE
/* We provide, as min size, the Icon size */
PROC min_size(ta, fh) OF icongad_plugin IS self.gad.width, self.gad.height
/* This is the render proc */
PROC render(ta, x,y, xs, ys, win:PTR TO window) OF icongad_plugin
IF self.gad
self.gad.leftedge:=x
self.gad.topedge :=y
AddGadget(win, self.gad, NIL)
-> The final argument to RefreshGList() ought to be 1, not 0
RefreshGList(self.gad, win, NIL, 1)
ENDIF
ENDPROC
/*
And here there is the clear proc
Since we have created a standard gadget, we simply
remove it from the gadget list of the window.
*/
PROC clear_render(win:PTR TO window) OF icongad_plugin
IF self.gad THEN IF win THEN RemoveGadget(win, self.gad)
ENDPROC
PROC message_test(imsg:PTR TO intuimessage, win:PTR TO window) OF icongad_plugin
-> Because we set the gadget's activation field we know we'll only get
-> IDCMP_GADGETUP generated by our gadget.
IF (imsg.class=IDCMP_GADGETUP) THEN RETURN imsg.iaddress=self.gad
ENDPROC FALSE
PROC message_action(a,b,c,d) OF icongad_plugin IS TRUE